package com.ossean.match.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ossean.match.model.Tag;


public interface TagDao {

	//@Select("select taggable_id from taggings where taggable_type='post' and id in (select id from tags where name=#{name})")
	@Select("select taggable_id from taggings where taggable_type='RelativeMemo' and tag_id in (select id from tags where name=#{name})")
	public List<Integer> getPosts(@Param("name")String name);

	//@Select("select id,name from tags where id in (select id from taggings where taggable_type='post' and taggable_id=#{postId})")
	@Select("select id,name from tags where id in (select tag_id from taggings where taggable_type='RelativeMemo' and taggable_id=#{postId})")
	public List<Tag> getTagsofPost(@Param("postId")int postId);
	
	@Select("select id,name from tags where id>#{startId} AND id<=#{endId}")
	public List<Tag> getBatchTag(@Param("startId")int startId,@Param("endId")int endId);
	
	@Select("select MAX(id) from tags")
	public Integer getNewLast();
}
